# First hardware project ***Copyright © Quectel Wireless Solutions Co., Ltd. 2026. All rights reserved.*** --- This chapter uses the IMX219 camera, an accessory supported by the Quectel Pi Development Kit, as an example to help you quickly get familiar with peripheral debugging on the Quectel Pi. --- # Take Your First Photo with the IMX219 Camera If you do not have an IMX219 camera module, you may skip this chapter. For a more detailed camera tutorial, see: [Camera](<../../User guide/Camera/Camera.md>) ## Install the Camera 1. Power off the development board. 2. Locate the MIPI CSI ribbon cable connector labeled **CAM0** or **CAM1** on the board. 3. Insert the IMX219 camera ribbon cable with the gold contacts facing down into the connector and secure the latch. 4. Power on and boot the board. > **Note**: The ribbon cable must not be inserted in the wrong direction — the gold contact side must face toward the circuit board (facing down). Always power off before installing or removing the ribbon cable.
image
image
## Control the Camera (GNOME) The camera can capture photos/record to file for viewing, or preview directly on the display desktop: ### Set Desktop Environment Variables The M1's Debian system uses GNOME as the default desktop. Copy and execute the following commands in the ADB terminal: ```bash # Not needed if you don't want to preview on the desktop # GNOME desktop export GST_V4L2_FORCE_LIBV4L2=0 export WAYLAND_DISPLAY=wayland-0 export XDG_RUNTIME_DIR=/run/user/1000 ``` ### Take a Photo Use camera=0/1 to distinguish cameras connected to different CSI slots. camera=0 represents the first CSI slot, and camera=1 represents the second CSI slot. The commands below use camera0 as an example. If using camera1, modify the camera device node path accordingly. | **Camera** | **Device Node Path** | | --- | --- | | camera0 | /dev/video33 | | camera1 | /dev/video51 | 1. Run the following commands in the device terminal: ```bash # Configure camera output to 1640×1232 NV12 raw data v4l2-ctl -d /dev/video33 --set-fmt-video=width=1640,height=1232,pixelformat=NV12 # Skip 5 frames, then capture 1 frame using mmap, and save as a YUV file. v4l2-ctl -d /dev/video33 --stream-mmap=2 --stream-skip=5 --stream-count=1 --stream-to=/tmp/raw_cam1.yuv # Use FFmpeg to encode this raw YUV frame into a JPEG image ffmpeg -f rawvideo -pix_fmt nv12 -s 1640x1232 -i /tmp/raw_cam1.yuv -frames:v 1 -q:v 2 /tmp/photo_cam1.jpg ``` 2. The image file is saved in the /tmp/ directory. ### Record Video 1. Run the following commands in the device terminal: ```bash # Configure camera output to 1640×1232 resolution, NV12 format raw data. v4l2-ctl -d /dev/video33 --set-fmt-video=width=1640,height=1232,pixelformat=NV12 # Use 4 buffers, skip the first 10 frames, continuously capture 60 frames of raw YUV data, and save to file. v4l2-ctl -d /dev/video33 --stream-mmap=4 --stream-skip=10 --stream-count=60 --stream-to=/tmp/rec_cam0.yuv # Interpret the raw YUV sequence at 30fps frame rate, compress with H.264 encoder, encoding preset set to fast, video bitrate set to 8 Mbps, and package into an MP4 video file. ffmpeg -f rawvideo -pix_fmt nv12 -s 1640x1232 -framerate 30 \ -i /tmp/rec_cam0.yuv -c:v h264 -preset fast -b:v 8M /tmp/rec_cam0.mp4 ``` 2. The MP4 file is saved in the /tmp/ directory. 3. To stop camera recording, press CTRL+C.